import {
    GETDATA,
    D
} from '../utils/R'
export default {
    namespace: 'rightBottomPage',
    state: {},
    subscriptions: {
        setup({
            dispatch,
            history
        }) {
            history.listen(({
                pathname
            }) => {
                if (pathname === '/one') {
                    dispatch({
                        type: 'getData'
                    })
                }
            })
        }
    },
    effects: {
        * getData({
            payload
        }, {
            call,
            put
        }) {
            let {
                data
            } = yield call(GETDATA, D)

            if (data) {
                let payload = [{
                    value: parseInt(data[0].boyRatio),
                    name: '男',

                }, {
                    value: parseInt(data[0].girlRatio),
                    name: '女',
                }]
                yield put({
                    type: 'setData',
                    payload
                })
            }
        }
    },
    reducers: {
        setData(state, action) {
            return action.payload
        }
    }
}